using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Entities;
using BUS;
using Utility;

public partial class Admin_dangnhap : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Url.ToString().Contains("dangnhap.aspx") == false && Session["tk"] == null)
            Response.Redirect("~/Admin/dangnhap.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Criteria cri = new Criteria();
        cri.add(Condition.AND, tbNhanVien.tbNhanVienColumns.TaiKhoan.ToString(), Condition.EQUAL, txttk.Text);
        int total = 0;
        tbNhanVien.tbNhanVienCollection nhanVienCollection = tbNhanVienBUS.Get(cri.Criter, 0, 0, tbNhanVien.tbNhanVienColumns.IDNhanVien.ToString(), OrderDirection.ASC.ToString(), out total);
        if (nhanVienCollection.Count > 0)
        {
            if (nhanVienCollection[0].MatKhau == txtmk.Text)
            {
                Session["tk"] = txttk.Text;
                Response.Redirect("~/Admin/sanphamlist.aspx");
            }
            else
            {
                lb_Error.Text = "Mat khau sai . Vui long dang nhap lai ";
            }
        }
             else
            {
                lb_Error.Text = "Tai khoan khong ton tai. Vui long dang nhap lai ";
            }
    }
}
